package com.group12.liuxinpeng.organ.service.impl;

import com.group12.liuxinpeng.mybatis.entity.PtOrganEntity;
import com.group12.liuxinpeng.mybatis.ztree.ZtreeEntity;
import com.group12.liuxinpeng.organ.repository.OrganDao;
import com.group12.liuxinpeng.organ.service.OrganService;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Locale;

@Service("organService")
public class OrganServiceImpl implements OrganService {

    @Resource
    private OrganDao organDao;
    @Resource
    private MessageSource messageSource;
    @Override
    public List<ZtreeEntity> getOrganZtreeListByOrganId(String organUuid) {
        Locale locale = LocaleContextHolder.getLocale();
        String msgStr = messageSource.getMessage("organ.info",null,locale);
        List<ZtreeEntity> list=organDao.getOrganZtreeList();
        ZtreeEntity root=new ZtreeEntity();
        root.setId("0");
        root.setpId("-1");
        root.setName(msgStr);
        list.add(root);
        System.out.println("666");
        return list;
    }

    @Override
    public void addOrgan(String organBianMa, String organName, String organType, String organBeiZhu) {
        organDao.addOrgan(organBianMa, organName, organType, organBeiZhu);
    }

    @Override
    public void delOrgan(String organBianMa){
        organDao.delOrgan(organBianMa);
    }
}
